# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tlspretense
pkgver=v0.6.2.r22.g0a5faf4
pkgrel=10
epoch=1
pkgdesc='SSL/TLS client testing framework.'
groups=('blackarch' 'blackarch-crypto' 'blackarch-scanner')
arch=('any')
url='https://github.com/iSECPartners/tlspretense'
license=('MIT')
depends=('ruby' 'ruby-bundler' 'libxslt')
makedepends=('git')
options=(!emptydirs)
source=("git+https://github.com/iSECPartners/$pkgname.git"
        "$pkgname.gemspec.patch")
sha512sums=('SKIP'
            '698f128e08c14cafef1385fe1cac4b80af346d4082727162f9aa5f097f43e3c3679a31f320f05d8daf798132fb8af465c7cb22534ade7fbd0742dc909a212951')
install="$pkgname.install"

prepare() {
  cd $pkgname

  patch < "$srcdir/$pkgname.gemspec.patch"
}

pkgver() {
  cd $pkgname

  git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.rdoc
  install -Dm 644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm LICENSE.txt

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bundle exec ./bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"

  #find "$pkgdir/usr/share/$pkgname/bin" -type f -exec chmod 755 {} \;
  #chmod 644 "$pkgdir/usr/share/$pkgname/"{Gemfile*,*gemspec}
}

